#include <iostream>
#include <string>
#include <mutex>
#include <thread>
#include <fstream>
using namespace std;
class log
{
public:
  static log *getInstance();
 
  /*
  void setLog_name(string log_name) { this->log_name = log_name; }
  string getLog_name() { return log_name; }
  void setTimes (int times){this->times = times;}
  time_t getTimes(){return times;}
   */     
        
  void writelog(const string &log);

  static void loginformation();
  ~log() = delete;

private:
  log() {}

private:
  static log *m_log;
  static mutex m_mutex;
  //static string log_name;
  //static int times;
};

int times = 2023;
string log_name = "log";
log *log::m_log = nullptr;
mutex log::m_mutex;
log *log::getInstance()
{
  if (m_log == nullptr)
  {
    lock_guard<mutex> lock(m_mutex);
    if (m_log == nullptr)
    {
      m_log = new log();
    }
  }
  return m_log;
}

void log::writelog(const string &log)
{

  cout << log << endl;
}
void log::loginformation()
{
  cout << log_name << " "<<times << endl;
}

int main(int argc, char *argv[])
{

  log::loginformation();
  log::getInstance()->writelog("this is log");

  return 0;
}